package com.itheima.case1;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class case3Runnable implements Runnable{

    static int i = 1;
    static Lock lock = new ReentrantLock();
    @Override
    public void run() {
        while(true){
            lock.lock();
            try{
                if(i > 100){
                    break;
                }else{

                    if(i%2 != 0){
                        System.out.println(i);
                    }
                    i++;
                }
            }catch (Exception e){
                e.printStackTrace();
            }finally {
                lock.unlock();
            }
        }
    }
}
